import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

import NotFind from '../views/NotFind.vue'

Vue.use(VueRouter)

// 跳转传参(多个参数) $route.query.参数名       /path?key1=?&key2=?
// 动态路由传参(单个参数) $route.params.参数名  /path/:key?


const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    // 路由懒加载 打包优化
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path: '*',
    component: NotFind
  }

]

const router = new VueRouter({
  // 路由模式, /#/这种显示不太自然
  mode: 'history',

  base: process.env.BASE_URL,
  routes,
  // 自定义简短高亮名称
  // 模糊
  linkActiveClass: 'active',
  // 精准
  linkExactActiveClass: 'exactActive'
})

export default router
